import Vue from 'vue';
import VueRouter from 'vue-router';
import Login from '../views/Login.vue';
import Layout from '@/components/Layout.vue';

Vue.use(VueRouter);
//公共路由
export const constantRoutes = [
    {
        path: '',
        component: Layout,
        redirect: 'home',
        hidden: true,
        children: [
            {
                path: 'home',
                component: () => import('@/views/Home.vue'),
                name: '首页',
                meta: {title: '首页', icon: 'el-icon-monitor', noCache: true, affix: true}
            }
        ]
    },
    {
        path: '/login',
        name: '用户登录',
        hidden: true,
        component: Login,
    },
    {
        path: '/user',
        name: '个人中心',
        hidden: true,
        component: Layout,
        children: [
            {
                path: 'profile',
                hidden: true,
                name: '个人信息',
                component: () => import('@/views/Profile.vue'),
                meta: {
                    title: '个人信息',
                    icon: ''
                }
            },
        ]
    },
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path*',
                hidden: true,
                component: () => import('@/components/Redirect.vue')
            }
        ]
    },
    {
        path: '/404',
        name: '404',
        hidden: true,
        meta: {title: '404'},
        component: () => import('@/views/404.vue')
    }
];

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: constantRoutes
});


export default router;
